Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to send additional fields with the auto complete query. #159

Closed
wants to merge 1 commit into from

Conversation

donv
Copy link
Contributor

@donv donv commented May 31, 2012

Hi!

In many cases you wish to send additional fields with the auto complete query. An example can be that you first select a project, and then use auto complete for a work record description text field, and you wish to prioritize previous work records from the same project before those from other projects.

This pull request adds a "fields" option to the FormHelper. The option is expected to contain a Ruby hash with names of query params as keys and CSS selectors for the referenced fields as values.

<%=form_for @work do |f| %>
  <%=f.autocomplete_field :description, '/works/auto_complete_work_description',
      :fields => {:project_id => '#work_project_id'}%>
<% end %>

The change should be backwards compatible and not affect any legacy code. Please merge and include in the next gem release.

@aiperon
Copy link

aiperon commented Jun 19, 2012

I think it's only frontend part of solution. It don't impact on result query.
It can be solved by changing files:

  • lib/rails3-jquery-autocomplete/autocomplete.rb
  • lib/rails3-jquery-autocomplete/orm/*.rb

I'll try complete feature as soon as possible.

@gugguson
Copy link

I'm currently implementing something similar (I have a field for a ingredient and I want a autocomplete for a qty field which would first filter by the ingredient field and then show only qty's (gramms, kilos etc.) valid for the selected ingredient. Can I use donv solution or will this be a part of the gem soon?

@aiperon
Copy link

aiperon commented Jun 22, 2012

Well, I don't know how you can use donv solution, because of that I dscribe early.
I'll fork donv:master, implement my solution, and send pull request to crowdint:master. Then you should be able to use my fork or waiting confirmation of pull reqest.
I'll do it at this weekend.

@gugguson
Copy link

Great, I will look into this after the weekend.

@gugguson
Copy link

Could this be a good implementation, multiple fields which can be passed to the controller: https://github.com/guiloyins/rails3-jquery-autocomplete

@aiperon
Copy link

aiperon commented Jun 24, 2012

guiloyins's implementation solve problem: ("company.name LIKE ? OR company.phone LIKE ?", term, term)
my and donv's problem looks like this: ("company.name LIKE ? AND company.city_id = ?", term, another_form_field)
I cann't detect your kind of problem, described in your first comment. Sorry for my english))

@gugguson
Copy link

Hello.

My problem is the second one, that is two different form fields into the query.

That is: ("company.name LIKE ? AND company.city_id = ?", term, another_form_field)

Thanks,
Johann

On 24.6.2012, at 17:38, [email protected] wrote:

guiloyins's implementation solve problem: ("company.name LIKE ? OR company.phone LIKE ?", term, term)
my and donv's problem looks like this: ("company.name LIKE ? AND company.city_id = ?", term, another_form_field)
I cann't detect your kind of problem, described in your first comment. Sorry for my english))


Reply to this email directly or view it on GitHub:
#159 (comment)

@zeitan
Copy link

zeitan commented Aug 19, 2013

Hi aiperon, does this feature exist the current verson of the gem?
Regards

@donv
Copy link
Contributor Author

donv commented Jan 8, 2014

I have submitted a new pull request which includes this feature with example in the README: #250

@donv donv closed this Jan 8, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants